package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetMealDishMapper {
    /**
     * 按照dishId查询当前菜品关联的套餐数量
     *
     * @param dishId
     * @return
     */
    @Select("select count(setmeal_dish.dish_id) from setmeal_dish where dish_id = #{dishId}")
    public Integer countByDishId(Long dishId);

    /**
     * 批量添加套餐关联的菜品
     * 没有哪些公共的变量就不要autofill了
     * @param setmealDishes
     */

    void insertBatch(List<SetmealDish> setmealDishes);

    /**
     * 根据套餐id获取菜品
     *
     * @param setMealId
     * @return
     */
    List<SetmealDish> getBySetMealId(Long setMealId);

    /**
     * 根据setmealid删除
     *
     * @param setMealId
     */

    @Delete("delete from setmeal_dish where setmeal_id = #{setMealId} ")
    void deleteBySetMealId(Long setMealId);

    /**
     * 根据setmeal的id集合删除对应的所有菜品
     * @param ids
     */
    void deleteBatch(List<Long> ids);
}
